<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>SEO设置</title>
</head>
<body>
	<!--{include file='comm/naviBanner.tpl'}-->
<div class="container">

    <!--{include file='comm/menu.tpl'}-->
	
        <div class="comm_crub">
            <span class="now_crub">SEO设置列表</span>
        </div>

        <div class="comm_content">

		    <div class="search-box" style="margin-top:10px;">
		        <div style="position:relative">
		            <form id="search_form" onsubmit="return false;">
		                <table style="width:100%;">
		                    <tbody>
		                    <tr>
		                        <td height="27px" style="width:10%;">
		
		                            类型：
		                            <select name="pageType" id="pageType" style="width:90px;">
		                                <option value="">请选择</option>
		                                <option value="1">首页</option>
		                                <option value="2">列表页</option>
		                                <option value="3">详情页</option>
		                            </select>
		
		                            &nbsp;
		
		                            <input type="button" value="查询" id="searchBtn" style="cursor: pointer;" class="btn" onclick="seolist.search();" />
		
		                            &nbsp;
		
		                            <input type="button" value="重置" id="clearBtn" style="cursor: pointer;" class="btn" onclick="seolist.clear();" />
		
		                        </td>
		                    </tr>
		
		                    </tbody>
		                </table>
		            </form>
		        </div>
		    </div>
		
		    <table id="flex" style="display:none"></table>
			
		</div>


    <!--{include file='comm/footer.tpl'}-->

</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/system/seo.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 100, align: "center"},
            {display: "类型", name : "createTime", width : 100, sortable : true,align:"right"},
            {display: "页面名称", width : 150 , align: "left"},
            {display: "标题", width : 200},
            {display: "关键字", width : 200},
            {display: "描述", width : 350},
            {display: "状态", width : 70,align:"center"}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "seolist.add"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "seolist.delcheck"}
        ],
        sortname: "createTime",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var seolist = {

        delArr: new Array(),

        uid:'',

        pageType:'',

        useFlg:'',

        //删除确认
        delcheck: function(){
            //获取选中的行的行数
            var selected_count = $('.trSelected',flex).length;
            if (selected_count==0) {
                E.alert('请选择要删除的seo');
                return;
            }else{
                var tempArr = new Array();
                for(var i=0; i<selected_count; i++){
                    var seoStr = $('.trSelected',flex).eq(i).attr('id');
                    var seoID = seoStr.substr(3);
                    tempArr.push(seoID);
                }
                this.delArr = tempArr;
				
                //弹出确认层
                E.confirm('确认删除这 ' + $('.trSelected',flex).length + ' 个seo吗?', "seolist.del");
            }

        },

        del:function(){
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/system/seo.ajax?operFlg=3",
                dataType: "JSON",
                data:{delArr: seolist.delArr},
                success: function(result_obj){
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "seolist.load");
                    }
                    else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        //搜索
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //添加
        add: function() {
            E.open("/quanliadmin/app/system/seo.pscript?operFlg=2" , "", {height: 500,width: 900, top: 50, left: 150});
        },

        //编辑
        edit: function(uid,pageType) {
            E.open("/quanliadmin/app/system/seo.pscript?operFlg=3&uid=" + uid + "&pageType=" + pageType , "", {height: 500,width: 900, top: 50, left: 150});
        },

        //禁用启用确认
        changeConfirm: function(uid ,pageType, flg) {

            this.uid = uid;
            this.pageType = pageType;
            this.useFlg      = flg;

            if( flg == 0 ){
                E.confirm("您确认 启用 吗？", "seolist.change");
            }else{
                E.confirm("您确认 禁用 吗？", "seolist.change");
            }

        },

        //禁用启用
        change: function() {
            jquery_ajax(4 , {uid:this.uid,pageType:this.pageType,flg:this.useFlg} , seolist.callback );
        },


        //回调函数
        callback: function( obj ) {

            if( obj.code == 200 ){
                E.alert( obj.message , 2 , 'seolist.load');
            }else{
                E.alert(obj.message);
            }

        },

        //重置
        clear:function(){
          $("#pageType").val('');
        },

        load: function() {
            $("#flex").flexReload();
        }

    };


    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/system/seo.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }

</script>

</body>

</html>
